#include "Viewport.h"
#include "SceneView.h"
#include "Runtime/Rendering/SceneRendering.h"
#include "GameViewportClient.h"

#include "Runtime/Logic/Engine.h"
#include "Runtime/Logic/World.h"

namespace Alice
{
    void GameViewportClient::Init(WorldContext& WorldContext, GameInstance* OwningGameInstance, bool bCreateNewAudioDevice)
    {
        mGameInstance=OwningGameInstance;
        mWorld=WorldContext.mWorld;
    }
    SceneViewport* GameViewportClient::CreateGameViewport(ViewportWidget* inViewportWidget)
    {
        return new SceneViewport(this,inViewportWidget);
    }
    void GameViewportClient::SetViewportFrame(ViewportFrame* inViewportFrame)
    {
        SetViewport(inViewportFrame->GetViewport());
    }
    void GameViewportClient::SetViewport(Viewport* inViewportFrame)
    {
        mViewport=inViewportFrame;
    }
    void GameViewportClient::Draw(Viewport* inViewport)
    {
        World*world=GetWorld();
        SceneViewFamily sceneViewFamily(inViewport,world->mScene);
        GetRendererModule()->BeginRenderingViewFamily(&sceneViewFamily);
    }
    World* GameViewportClient::GetWorld() const
    {
        return mWorld;
    }
    GameInstance* GameViewportClient::GetGameInstance() const
    {
        return mGameInstance;
    }
}
